﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OsPortal;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for clsLogNapGold
/// </summary>
public class clsLogNapGold
{
    public struct stLogNapGold
    {
        public Int32 NG_ID;
        public String US_ID;
        public String ng_seria;
        public String ng_code;
        public String ng_nhamang;
        public DateTime ng_ngaynap;
        public Double ng_menhgia;
    } 

    /// <summary>
    /// Ghi Log lịch sử nạp thẻ của users
    /// </summary>
    /// <param name="st"></param>
    /// <returns></returns>
    public static bool Add(stLogNapGold st)
    {

        bool rs = false;
        try
        {
            string strSQL = "";
            strSQL += "INSERT INTO";
            strSQL += " LOGNAPGOLD(US_ID, NG_SERIA, NG_CODE, NG_NHAMANG, NG_MENHGIA)";
            strSQL += " VALUES('" + st.US_ID + "','" + st.ng_seria + "','" + st.ng_code + "','" + st.ng_nhamang + "'," + st.ng_menhgia + ")";
            oSqlDataHelper.sExecute(strSQL);
            rs = true;
        }
        catch (Exception ex)
        {
            oFileHelper.WriteLogErr("clsLogNapGold", "Add", ex.ToString());
            rs = false;
        }
        return rs;
    }

    /// <summary>
    /// Lấy danh sách lịch sử nạp Gold của users
    /// </summary>
    /// <param name="st"></param>
    /// <returns></returns>
    public static DataTable Get_by_UsersID(string strUS_ID)
    {
        try
        {
            string strSQL = "SELECT * FROM LOGNAPGOLD WHERE US_ID='" + strUS_ID + "'";
            return oSqlDataHelper.sExecuteDataTable(strSQL);
        }
        catch (Exception ex)
        {
            oFileHelper.WriteLogErr("clsLogNapGold", "Get_by_UsersID", ex.ToString());
            return null;
        }
    }
}